<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'].'/');
$path = ROOT_DIR.'setting.php';
$settingsContent = file_get_contents($path);
$title = $_POST['title'];
$beian = $_POST['beian'];
$ai_open = $_POST['ai_open'];
$keyword = $_POST['keyword'];
$call = $_POST['call'];
$newSettingMailArray = <<<EOT
\$index_array = array( //网站主体配置
    'title' => '$title', //网站标题
    'beian' => '$beian', //网站备案号
    'ai_open' => '$ai_open', //开启AI-付费服务
    'keyword' => '$keyword', //网站关键字
    'call' => '$call', //联系方式
);
EOT;
$pattern = '/\$index_array = array\(.*?\);/s';
$replacement = $newSettingMailArray;
$updatedSettingsContent = preg_replace($pattern, $replacement, $settingsContent);
file_put_contents($path, $updatedSettingsContent);
echo '<script>alert("修改成功");window.location.href="../../pluginset.php?s=exam";</script>';